//
//  LPTPhysicianListTableViewCell.m
//  LPTClient
//
//  Created by mac on 2018/12/8.
//  Copyright © 2018年 zhaodd. All rights reserved.
//

#import "LPTPhysicianListTableViewCell.h"

@interface LPTPhysicianListTableViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UILabel *statusLabel;
@property (weak, nonatomic) IBOutlet UILabel *orderNumberLabel;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *phoneNumLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UIButton *zhenduanBtn;
@property (weak, nonatomic) IBOutlet UIButton *sendMsgLabel;

@end

@implementation LPTPhysicianListTableViewCell

- (void)awakeFromNib {
    
    [super awakeFromNib];
    
    self.zhenduanBtn.layer.cornerRadius = 10.0f;
    self.zhenduanBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.zhenduanBtn.layer.masksToBounds = YES;
    self.zhenduanBtn.layer.borderWidth = 0.5f;
    
    self.sendMsgLabel.layer.cornerRadius = 10.0f;
    self.sendMsgLabel.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.sendMsgLabel.layer.masksToBounds = YES;
    self.sendMsgLabel.layer.borderWidth = 0.5f;
}

-(void)refreshWithDic:(NSDictionary *)dic
{
    self.dateLabel.text = dic[@"created_at"];
    
    NSString *statusStr;
    if ([dic[@"status"] integerValue] == 0) {
        
        statusStr = @"待付款";
        self.sendMsgLabel.hidden = YES;
        [self.zhenduanBtn setTitle:@"查看" forState:UIControlStateNormal];
        
    }else if ([dic[@"status"] integerValue] == 1){
        
        statusStr = @"待诊断";
        [self.zhenduanBtn setTitle:@"诊断" forState:UIControlStateNormal];
        self.sendMsgLabel.hidden = NO;
        
    }else if ([dic[@"status"] integerValue] == 2){
        
        statusStr = @"待评价";
        self.sendMsgLabel.hidden = YES;
        [self.zhenduanBtn setTitle:@"查看" forState:UIControlStateNormal];
        
    }else{
        
        statusStr = @"已完成";
        self.sendMsgLabel.hidden = YES;
        [self.zhenduanBtn setTitle:@"查看" forState:UIControlStateNormal];
    }
    
    self.statusLabel.text = statusStr;
    
    self.orderNumberLabel.text = [NSString stringWithFormat:@"姓名:  %@",dic[@"archive"][@"name"]];
    
    self.nameLabel.text = [NSString stringWithFormat:@"性别:  %@",[dic[@"archive"][@"sex"] integerValue] == 1?@"男":@"女"];
    
    self.phoneNumLabel.text = [NSString stringWithFormat:@"症状:  %@",dic[@"complaint"][@"symptom"]];
    
    self.priceLabel.text = [NSString stringWithFormat:@"¥%@",dic[@"amount"]];
    
}

- (IBAction)zhenduanAction:(id)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(physicianListTableViewCell:didClickBtnWithIndex:)]) {
        [self.delegate physicianListTableViewCell:self didClickBtnWithIndex:0];
    }
}

- (IBAction)sendMsgAction:(id)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(physicianListTableViewCell:didClickBtnWithIndex:)]) {
        [self.delegate physicianListTableViewCell:self didClickBtnWithIndex:1];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
